package com.zzyl;


import cn.hutool.http.*;
import cn.hutool.json.JSONUtil;
import org.junit.Test;

import java.util.HashMap;

public class test {
    @Test
    public void test01() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("pageNum", "1");
        map.put("pageSize", "2");
      /* String s = HttpUtil.get("localhost:9995/nursing_project",map);
       JSONObject entries = JSONUtil.parseObj(s);
       JSONObject data = (JSONObject) entries.get("data");
       Object o = data.get("records");
       System.out.println(o);*/

        HttpResponse execute = HttpUtil.createRequest(Method.GET, "localhost:9995/nursing_project").form(map).execute();
        System.out.println(execute.body());
    }

    @Test
    public void test02() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("name", "mmmm00");
        map.put("orderNo", "1");
        map.put("price", "200");
        map.put("status", "1");
        map.put("unit", "次");
       /* String s = HttpUtil.post("localhost:9995/nursing_project",JSONUtil.toJsonStr(map));
        System.out.println(s);*/

        HttpResponse execute = HttpUtil.createRequest(Method.POST, "http://localhost:9995/nursing_project")
                .body(JSONUtil.toJsonStr(map)).execute();
        System.out.println(execute);
    }

    @Test
    public void tianqi() {
        String appcode = "fc03c4b797bb457a9a98193c0db81aab";
        HashMap<String, Object> map = new HashMap<>();
        map.put("needday", "1");
        map.put("prov", "山东");
        map.put("city", "济南");
        HttpResponse s = HttpUtil.createRequest(Method.GET, "https://iweather.market.alicloudapi.com/address")
                .header("Authorization", "APPCODE " + appcode)
                .form(map).execute();

        System.out.println(s.body());

    }


}
